package com.yoake.cine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoake.common.annotation.Log;
import com.yoake.common.core.controller.BaseController;
import com.yoake.common.core.domain.AjaxResult;
import com.yoake.common.enums.BusinessType;
import com.yoake.cine.domain.Movie;
import com.yoake.cine.service.IMovieService;
import com.yoake.common.utils.poi.ExcelUtil;
import com.yoake.common.core.page.TableDataInfo;

/**
 * 电影信息管理Controller
 * 
 * @author yoake
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/cine/movie")
public class MovieController extends BaseController
{
    @Autowired
    private IMovieService movieService;

    /**
     * 查询电影信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:list')")
    @GetMapping("/list")
    public TableDataInfo list(Movie movie)
    {
        startPage();
        List<Movie> list = movieService.selectMovieList(movie);
        return getDataTable(list);
    }

    /**
     * 导出电影信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:export')")
    @Log(title = "电影信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Movie movie)
    {
        List<Movie> list = movieService.selectMovieList(movie);
        ExcelUtil<Movie> util = new ExcelUtil<Movie>(Movie.class);
        util.exportExcel(response, list, "电影信息管理数据");
    }

    /**
     * 获取电影信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:query')")
    @GetMapping(value = "/{movieId}")
    public AjaxResult getInfo(@PathVariable("movieId") String movieId)
    {
        return success(movieService.selectMovieByMovieId(movieId));
    }

    /**
     * 新增电影信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:add')")
    @Log(title = "电影信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Movie movie)
    {
        return toAjax(movieService.insertMovie(movie));
    }

    /**
     * 修改电影信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:edit')")
    @Log(title = "电影信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Movie movie)
    {
        return toAjax(movieService.updateMovie(movie));
    }

    /**
     * 删除电影信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:movie:remove')")
    @Log(title = "电影信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieIds}")
    public AjaxResult remove(@PathVariable String[] movieIds)
    {
        return toAjax(movieService.deleteMovieByMovieIds(movieIds));
    }
}
